# coding=utf-8
#

"""
error code
"""


from .http import make_api_response


class ErrorResponse(object):
    """ 错误码 """

    SERVER_ERROR = "500.1"

    NO_SUCH_USER = "400.1"
    WRONG_PASSWORD = "400.3"
    INCORRECT_NTYPE = "400.5"

    INVALID_TOKEN = "403.5"

    PARAMS_MISS = "404.1"
    DATA_NOT_EXIST ="404.2"
    INVALID_ACCOUNT_AK ="404.5"
    INVALID_STRATEGY = "404.7"
    INVALID_USER_ID = "404.17"

    mapping = {
        PARAMS_MISS: "缺少参数，请检查输入",
        SERVER_ERROR: "系统错误，请稍候重试",
        INVALID_USER_ID: "无效的用户ID",
        DATA_NOT_EXIST:"该数据不存在",
        INCORRECT_NTYPE: "消息类型不正确,请检查输入参数",
        INVALID_TOKEN: "Token校验不通过,请检查输入参数",
        INVALID_ACCOUNT_AK: "账号AK不正确，请检查输入",
        INVALID_STRATEGY: "策略未订阅，请检查输入",
    }

    @classmethod
    def get(cls, code, detail=None):
        code = code if code in cls.mapping else cls.SERVER_ERROR
        status_code = int(code.split(".")[0])

        return make_api_response(message=cls.mapping[code], status_code=status_code)
